package discount
// DiscountContext 折扣上下文
type DiscountContext struct {
	User             User             // 用户信息
	Order            Order            // 订单信息
	DiscountStrategy DiscountStrategy // 折扣策略
}

func (r *DiscountContext) SetStrategy(strategy DiscountStrategy) {
	r.DiscountStrategy = strategy
}

func (r *DiscountContext) GetDiscount() float64 {
	if r.DiscountStrategy == nil {
		r.SetStrategy(NewNoDiscountStrategy())
	}
	return r.DiscountStrategy.CalculateTotalAmount(r)
}